package com.ty.day7;

import java.util.Arrays;

/**
 * Created by IntelliJ IDEA.
 * Author : txy
 * Create 2023/11/3 15:29
 */
public class Four {
    public static void main(String[] args) {
        int[] a = new int[13];
        for (int i = 0; i < a.length; i++) {
            a[i] = i + 1;
        }
        System.out.println(Arrays.toString(a));
        int l = 0;
        while (true) {
            for (int i = 0; i < a.length; i++) {
                if (a[i] != 0) {
                    l = l + 1;
                    System.out.println(a[i] + "报数：" + l);
                }
                if (l % 3 == 0) {
                    a[i] = 0;
                    l = 0;
                }
            }
            int flag = 0;
            for (int j : a) {
                if (j != 0) {
                    flag = flag + 1;
                }
            }
            if (flag == 1) {
                break;
            }
        }
        for (int j : a) {
            if (j != 0) {
                System.out.println("幸存者：" + j);
                break;
            }
        }
    }
}
